package com.hg.forSearch.db.dao;

import java.util.ArrayList;
import java.util.List;

import org.jdiy.core.Args;
import org.jdiy.core.Ls;
import org.jdiy.core.Rs;

import com.hg.forSearch.db.dto.ForSearchDTO;
import com.hg.util.db.IDao;

public class ForSearchDAO extends IDao
{
	public ForSearchDTO encapsulation(Rs rs){
		ForSearchDTO dto = new ForSearchDTO();
		
		dto.setId(rs.getString("id"));
		dto.setName(rs.getString("name"));
		
		return dto;
	}
	
	public List<ForSearchDTO> getAll(String table){
		Args args = new Args(table);
		args.setFilter("1=1");
		args.setCols("id,name");
		Ls ls = dao.ls(args);
		List<ForSearchDTO> list = new ArrayList<ForSearchDTO>();
		for(Rs rs:ls.getItems()){
			list.add(this.encapsulation(rs));
		}
		return list;
	}
}
